package com.hermit.qmst.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.hermit.qmst.R;
import com.hermit.qmst.mode.MessageInfo;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2016/10/15 0015.
 */
public class AuthorityAdapter extends BaseAdapter {
    public List<MessageInfo> data;
    private Context context;

    public AuthorityAdapter(Context context) {
        this.context = context;
        data = new ArrayList<MessageInfo>();
    }

    @Override
    public int getCount() {
        return data.size();
    }

    @Override
    public Object getItem(int position) {
        return data.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        Holder holder = null;
        if (convertView == null) {
            holder = new Holder();
            convertView = LayoutInflater.from(context).inflate(R.layout.item_authority, null);
            holder.tv_title = (TextView) convertView.findViewById(R.id.tv_title);
            holder.tv_year = (TextView) convertView.findViewById(R.id.tv_year);
            holder.tv_content = (TextView) convertView.findViewById(R.id.tv_content);
            convertView.setTag(holder);
        } else {
            holder = (Holder) convertView.getTag();
        }

        holder.tv_title.setText(data.get(position).getTitle());
        holder.tv_year.setText(data.get(position).getCreatetime());
        holder.tv_content.setText(data.get(position).getContent());

        return convertView;
    }

    class Holder {
        TextView tv_title;
        TextView tv_year;
        TextView tv_content;
    }
}
